<?php
/**
 * TaskService.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-04-17 10:11:36
 * @modified    2023-04-17 10:11:36
 *
 */

namespace App\Services;

use App\Models\DictDataModel;
use App\Models\DictModel;

class TaskService
{
    private $types;

    public function __construct()
    {

    }

    public function types()
    {
        if (!is_null($this->types)) {
            return $this->types;
        }
        $data = DictModel::query()
            ->from('dict as d')
            ->select(['dd.name'])
            ->join('dict_data as dd', 'dd.dict_id', '=', 'd.id')
            ->where('d.code', '=', 'task_type')
            ->where('dd.mark', '=', 1)
            ->get()
            ->pluck('name')
            ->toArray();
        $this->types = $data;
        return $this->types;
    }
}